﻿using System.Collections.Generic;
using System.Threading.Tasks;
using SDCloudSolution.SDCloud.Entities;
using SDCloudSolution.SDCloud.Entities.Models;

namespace SDCloudSolution.SDCloud.DataLayer.Model.Interfaces
{
    /// <summary>
    /// Provides methods for works with model run storage.
    /// </summary>
    public interface IModelRunDataProvider
    {
        /// <summary>
        /// Gets a specific model run information by specific identifier.
        /// </summary>
        /// <param name="modelRunId">The model run identifier.</param>
        Task<ModelRunEntity> GetByIdAsync(int modelRunId);

        /// <summary>
        /// Gets a collection with paging of model runs for specific model identifier.
        /// </summary>
        /// <param name="modelId">The model identifier.</param>
        /// <param name="paging">The paging.</param>
        Task<EntityCollection<ModelRunEntity>> GetByModelIdAsync(int modelId, Paging paging);

        Task<EntityCollection<ModelRunEntity>> FindByModelIdsAndStatusesAsync(IEnumerable<int> modelIds, IEnumerable<ModelRunStatus> statuses, Paging paging);

        Task<EntityCollection<ModelRunEntity>> FindByModelIdsAsync(IEnumerable<int> modelIds, Paging paging);

        /// <summary>
        /// Finds a collection with paging of model runs for specific model identifier and filtered by specific status.
        /// </summary>
        /// <param name="modelId">The model identifier.</param>
        /// <param name="status">The status.</param>
        /// <param name="paging">The paging.</param>
        Task<EntityCollection<ModelRunEntity>> FindByModelIdAndStatusAsync(int modelId, ModelRunStatus status, Paging paging);

        Task<ModelRunEntity> FindLastModelRunAsync(int modelId);

        /// <summary>
        /// Enqueue a few model runs from queue.
        /// </summary>
        /// <param name="count">The count.</param>
        Task<ModelRunEntity> EnqueueAsync(int count);

        /// <summary>
        /// Inserts a new instance of model run.
        /// </summary>
        /// <param name="entity">The entity.</param>
        Task InsertAsync(ModelRunEntity entity);

        /// <summary>
        /// Updates an exists instance of model run.
        /// </summary>
        /// <param name="entity">The entity.</param>
        Task UpdateAsync(ModelRunEntity entity);
    }
}
